<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<jsp:include page="frame/header.jsp"></jsp:include>

<title>处理客户订单</title>

<style>
.left_title{
	font-weight:bold;
	width:20%;
}
</style>
</head>

<body>
	<div class="container-fluid">
		<div class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">商家管理</a> <span class="divider">/</span></li>
					<li><a href="#">订单管理</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-edit"></i> 客户订单处理
					</h2>
					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<form id="myform" class="" method="post" action="<c:url value="/seller/order" />">
						<fieldset>
							<h4>订单信息</h4>
							<br>
							<input type="hidden" name="orderId" value="${order.orderId }">
							<input type="hidden" name="status" id="status">
							<table id="order" class="table ">
							<tr>
								<td class="left_title">
									订单号：
								</td>
								<td>
									${order.orderNum }
								</td>
								<td class="left_title">
									下单时间：
								</td>
								<td>
									${order.createTime }
								</td>
							</tr>
							<tr>
								<td class="left_title">
									订餐日期：
								</td>
								<td>
									${order.orderDate }
								</td>
								<td class="left_title">
									订餐时间：
								</td>
								<td>
									${order.orderTime }
								</td>
							</tr>
							
							<tr>
								<td class="left_title" >
									订单状态：
								</td>
								<td colspan=3>
									<c:choose>
											<c:when test='${order.status == 0 }'>
												未处理
											</c:when>
											<c:when test='${order.status == 1 }'>
												已发货
											</c:when>
											<c:when test='${order.status == 2 }'>
												已完成
											</c:when>
											<c:when test='${order.status == 3 }'>
												已失效
											</c:when>
										</c:choose>	
								</td>
							</tr>
							
							<tr>
								<td class="left_title" >
									客户备注：
								</td>
								<td colspan=3>
									${order.description_mc }
								</td>
							</tr>
							</table>
							
							
							</fieldset>
							
							<fieldset>
							<h4>客户信息</h4>
							<br>
							
							<table id="customer" class="table ">
							<tr>
								<td class="left_title">
									客户名称：
								</td>
								<td>
									${order.customer.name }
								</td>
								<td class="left_title">
									商家名称：
								</td>
								<td>
									${order.seller.sellerName }
								</td>
							</tr>
							<tr>
								<td class="left_title">
									客户地址：
								</td>
								<td>
									${order.customer.address }
								</td>
								<td class="left_title">
									联系方式：
								</td>
								<td>
									${order.customer.link }
								</td>
							</tr>
							
							<tr>
								<td class="left_title" >
									详细信息：
								</td>
								<td colspan=3>
									${order.customer.description_mc }
								</td>
							</tr>
							</table>
							
							
							</fieldset>
							
							<fieldset>
							<h4>订餐明细</h4>
							<br>
							
							<table id="items" class="table table-striped table-bordered ">
						<thead>
							<tr>
								<th width="50">序号</th>
								<th >菜品名称</th>
								<th >菜单分类</th>
								<th >价格</th>
								<th >折扣</th>
								<th >预定份数</th>
								<th >备注</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="item" items="${order.itemList }" varStatus="status">
								<tr>
									<td>${status.index+1 }</td>
									<td>${item.foodName }</td>
									<td>${item.foodMenu } </td>
									<td class="price">${item.price } </td>
									<td>${item.rebate }</td>
									<td class="amount">${item.amount }</td>
									<td>${item.description_mc }</td>
								</tr>
							</c:forEach>
							
							<tr>
									<td>合计：</td>
									<td>&nbsp;</td>
									<td>&nbsp; </td>
									<td class="total_price">${order.statis.price} </td>
									<td>&nbsp;</td>
									<td class="total_amount">${order.statis.amount }</td>
									<td class="total_price_rebate">${order.statis.priceRebate }</td>
								</tr>
						</tbody>
					</table>
							
							</fieldset>
							
						<fieldSet>

							<div class="form-actions center">
								<c:choose>
									<c:when test='${order.status == 0 }'>
												<button id="prepareBtn" type="button" class="btn btn-primary">准备配送</button>
								<button id="balanceBtn" type="button" class="btn btn-success">订餐结算</button>
								<button id="cancelOrderBtn" type="button" class="btn btn-warning">取消订单</button>
											</c:when>
									<c:when test='${order.status == 1 }'>
												<button id="prepareBtn" type="button" disabled class="btn btn-primary">准备配送</button>
								<button id="balanceBtn" type="button" class="btn btn-success">订餐结算</button>
								<button id="cancelOrderBtn" type="button" class="btn btn-warning">取消订单</button>
											</c:when>
									<c:when test='${order.status == 2 }'>
												<button id="prepareBtn" type="button" disabled class="btn btn-primary">准备配送</button>
								<button id="balanceBtn" type="button" disabled class="btn btn-success">订餐结算</button>
								<button id="cancelOrderBtn" type="button"  class="btn btn-warning">取消订单</button>
											</c:when>
									<c:when test='${order.status == 3 }'>
												
								<button id="reBackOrderBtn" type="button" class="btn btn-warning">恢复失效订单</button>
											</c:when>
								</c:choose>
								
								<button id="cancelBtn" type="button" class="btn">返回</button>
							</div>
						</fieldset>
					</form>

				</div>
			</div>
			<!--/span-->

		</div>
	</div>
	<!--/row-->
</body>

<jsp:include page="frame/scripts.jsp"></jsp:include>
<script type="text/javascript">
$(document).ready(function(){
	
	$('#cancelBtn').click(function(){
		window.location.href = '<c:url value="/seller/order" />';	
	})
	
	$("#myform").validation();	
	
	//保存
	$('#prepareBtn').click(function(){
		$("#status").val(1);
		$("#myform").submit();
	})
	$('#balanceBtn').click(function(){
		$("#status").val(2);
		$("#myform").submit();
	})
	$('#cancelOrderBtn').click(function(){
		$("#status").val(3);
		$("#myform").submit();
	})
	$('#reBackOrderBtn').click(function(){
		$("#status").val(1);
		$("#myform").submit();
	})
})


</script>